package org.example.beans;

import org.springframework.stereotype.Component;

/**
 * 单例作用域Bean - 整个Spring容器中只创建一个实例
 * 这是Spring的默认作用域
 */
@Component
public class SingletonBean {
    
    private final String instanceId;
    
    public SingletonBean() {
        this.instanceId = "SingletonBean-" + System.currentTimeMillis() + "-" + this.hashCode();
        System.out.println("创建SingletonBean实例: " + instanceId);
    }
    
    public String getInstanceId() {
        return instanceId;
    }
    
    public void doSomething() {
        System.out.println("SingletonBean执行任务，实例ID: " + instanceId);
    }
} 